package com.jiazhong.basic.shuxin.thread.b;

import lombok.SneakyThrows;

// 生产者
public class Product implements Runnable {

    private Broker broker;

    public Product(Broker broker) {
        this.broker = broker;
    }

    @SneakyThrows
    public void run() {
        for (int i = 0; i < 20; i++) {
            Goods g = new Goods();
            g.setId(i + 1);
            System.out.println("厂家生产了:" + g);
            broker.purchase(g);
            Thread.sleep(1000);
        }
    }
}
